﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace NewsReaderApp.Views
{
    /// <summary>
    /// If item is null this template selector returns null as a template, otherwise, it returns a default template specified
    /// in the <see cref="Default">DefaultTemplate</see> property
    /// </summary>
    public sealed class DefaultTemplateSelector : DataTemplateSelector
    {
        public DataTemplate DefaultTemplate
        {
            get;
            set;
        }
        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            if (item == null)
                return null;
            else
                return DefaultTemplate;
        }
    }
}
